//该文件用于创建整个应用的路由器
import Router from 'vue-router'

import About from '../pages/About.vue'
import Home from '../pages/Home.vue'
import Message from '../pages/Message.vue'
import News from '../pages/News.vue'
import Detail from '../pages/Detail.vue'

export default new Router({
    routes:[
        {
            name:'guanyu',
            path:'/about',
            component:About
        },
        {
            path:'/home',
            component:Home,
            children:[
                {
                    path:'message',
                    component:Message,
                    children:[
                        {
                            name:'xiangxi',
                            path:'detail/:id/:msg',
                            component:Detail,
                            
                            // props的第一种写法，对象写法，该对象中所有key-value都会以props的形式传给Detail组件
                            //props:{ids:'666',msgs:'啊啊啊'}
                            
                            //props的第二种写法，布尔值为true，就会把该路由组件收到的所有params参数以props形式传给Detail组件
                            // props:true

                            //props的第三种写法：函数写法
                            props($route){
                                return {id:$route.params.id,msg:$route.params.msg}
                            }
                        }
                    ]
                },
                {
                    path:'news',
                    component:News
                }
            ]
        },
    ]
})